package com.chehongwei;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Aspect
@Component
public class SpringAOPDemo {

    @Around("execution(* com.chehongwei.springaop.service.*.*(..))")
    public Object aop(ProceedingJoinPoint pjp) throws Throwable {

        long startTime = System.currentTimeMillis();

        Object ret = pjp.proceed();

        long endTime = System.currentTimeMillis();

        System.out.println("记录: " + pjp.getTarget() + "." + pjp.getSignature() + "耗时：" + (endTime - startTime) * 1000 + " 秒");

        return ret;
    }


}
